# 自动化步骤
# 安装 selenium库
import time
from selenium import webdriver
from selenium.webdriver import Keys
from selenium.webdriver.common.by import By

# 创建驱动对象
driver = webdriver.Edge()
# 打开网页
driver.get("file:///D:/pagetest/注册A.html")

# 定位到账号输入框，输入王宝强强
# ele = driver.find_element(By.CSS_SELECTOR,'#userA')
# ele.send_keys('王宝强强')
# time.sleep(3)
#
# # 删除键 backspace
# ele.send_keys(Keys.BACK_SPACE)
# time.sleep(3)
#
# # 组合键
# # 全选用户名，ctrl + a
# ele.send_keys(Keys.CONTROL,'a')
# time.sleep(3)
# # 复制
# ele.send_keys(Keys.CONTROL,'c')
# # 粘贴到电话号码框
# ele1 = driver.find_element(By.CSS_SELECTOR,'#telA')
# ele.send_keys(Keys.CONTROL,'v')
# 在text1中输入12345678
ele = driver.find_element(By.XPATH,'//*[@id="p1"]/input')
ele.send_keys('12345678')
time.sleep(2)
# 复制text1中的内容到text2 删除text2中12345678的8和7，在添加99
ele.send_keys(Keys.CONTROL,'c')
ele2 = driver.find_element(By.XPATH,'//*[@id="p2"]/input')
ele2.send_keys(Keys.CONTROL,'v')
ele2.send_keys(Keys.BACKSPACE)
ele2.send_keys(Keys.BACKSPACE)
ele2.send_keys('99')
time.sleep(2)
# 复制text1中的内容到text3  修改test3内容为'王大锤'
ele3 = driver.find_element(By.XPATH,'//*[@id="p3"]/input')
ele.send_keys(Keys.CONTROL,'c')
ele3.send_keys(Keys.CONTROL,'v')
ele3.send_keys(Keys.CONTROL,'a')
ele3.send_keys('王大锤')
time.sleep(2)
# 复制text1的内容到text4中 删除text4中12345678 中的6
ele4 = driver.find_element(By.XPATH,'//*[@id="p4"]/input')
ele.send_keys(Keys.CONTROL,'c')
ele4.send_keys(Keys.CONTROL,'v')
ele4.send_keys(Keys.LEFT)
ele4.send_keys(Keys.LEFT)
ele4.send_keys(Keys.BACKSPACE)
# # 关闭网页
time.sleep(60)
driver.quit()






























